import java.io.FileOutputStream;
import java.io.PrintStream;

/*
 * !Drowning
 * May 29, 2011
 * TCSS 360
 * Schedule Project
 */


/**
 * Class that handles all the user inputs through files and also
 * holds the collection of courses and users.
 * 
 * @version May 29, 2011
 * @author David Phillips
 */

public class SchedulingMain {
	
	/**
	 * All the courses.
	 */
	private Courses my_courses; 
	
	/**
	 * All the users.
	 */
	private Users my_users;

	/**
	 * The main.
	 * @param args the args.
	 */
	public static void main(String[] args) {
		new SchedulingMain().start();
	}
	
	/**
	 * Start the program.
	 */
	public void start() {
		System.out.println("System Start - Loading from local directory");

		my_courses = new Courses("schedule.csv");
		
		System.out.println("\tall courses loaded from schedule.csv");
		
		my_users = new Users("users.csv");
		
		System.out.println("\tall users loaded from users.csv");
		
		Schedule the_schedule = new Schedule();
		output(the_schedule.doTests(my_courses, my_users));
	}

	/**
	 * Print stuff.
	 * @param out stuff to print
	 */
	private static void output(String out) {
		 FileOutputStream aFileOutStream;
	     PrintStream aPrintStream; 
	        try
	        { 
	                aFileOutStream = new FileOutputStream("constraints.txt");
	                aPrintStream = new PrintStream( aFileOutStream );
	                aPrintStream.format(out);
	                aPrintStream.close();
	        }
	        catch (Exception e)
	        {
	                System.err.println ("Error writing to file");
	        }
		
	}
	
	
}
